import processing.core.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
 
DropTarget dt = new DropTarget(this, new DropTargetListener() {
  public void dragEnter(DropTargetDragEvent event) {
    // debug messages for diagnostics
    //System.out.println("dragEnter " + event);
    event.acceptDrag(DnDConstants.ACTION_COPY);
  }
 
  public void dragExit(DropTargetEvent event) {
    //System.out.println("dragExit " + event);
  }
 
  public void dragOver(DropTargetDragEvent event) {
    //System.out.println("dragOver " + event);
    event.acceptDrag(DnDConstants.ACTION_COPY);
  }
 
  public void dropActionChanged(DropTargetDragEvent event) {
    //System.out.println("dropActionChanged " + event);
  }
 
  public void drop(DropTargetDropEvent event) {
    //System.out.println("drop " + event);
    event.acceptDrop(DnDConstants.ACTION_COPY);
 
    Transferable transferable = event.getTransferable();
    DataFlavor flavors[] = transferable.getTransferDataFlavors();
    int successful = 0;
 
    for (int i = 0; i < flavors.length; i++) {
 try {
   Object stuff = transferable.getTransferData(flavors[i]);
   if (!(stuff instanceof java.util.List)) continue;
   java.util.List list = (java.util.List) stuff;
 
   for (int j = 0; j < list.size(); j++) {
     Object item = list.get(j);
     if (item instanceof File) {
  File file = (File) item;
 
       
  String filename = file.getPath();
  loadFile(filename);
  System.out.println(filename);
     }
   }
 
 }  
 catch (Exception e) {
   e.printStackTrace();
 }
    }
  }
}
); 
